//
//  Recorder.h
//  AudioQueueDemo
//
//  Created by marco on 16/3/8.
//  Copyright © 2016年 Marco. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <CoreAudio/CoreAudioTypes.h>
#import "RecorderConfig.h"




// Audio Settings

#define kNumberBuffers      3
#define t_sample            SInt16
#define kSamplingRate       16000
#define kNumberChannels     1
#define kBitsPerChannels    (sizeof(t_sample) * 8)
#define kBytesPerFrame      (kNumberChannels * sizeof(t_sample))
#define kFrameSize          1000

extern NSString * const  g_kRecorderProcessAudioBuffer;


typedef struct AQCallbackStruct

{
    AudioQueueLevelMeterState *levels;
    AudioStreamBasicDescription mDataFormat;
    AudioQueueRef               queue;
    AudioQueueBufferRef         mBuffers[kNumberBuffers];
    AudioFileID                 outputFile;
    unsigned long               frameSize;
    long long                   recPtr;
    int                         run;
    
} AQCallbackStruct;

@class AQQueue;

#define kRECORDER_8kb    8000
#define kRECORDER_16KB   16000

@interface Recorder : NSObject


@property (nonatomic, assign) AQCallbackStruct aqc;
@property (nonatomic,weak) AQQueue *voiceDataQueue;

- (id) initWithSampleRate:(NSInteger)pSampleRate;
- (void) start;
- (void) stop;
- (void) pause;
- (void) processAudioBuffer:(AudioQueueBufferRef) buffer withQueue:(AudioQueueRef) queue;


static void AudioPlayerAQInputCallback(void *input, AudioQueueRef inQ, AudioQueueBufferRef outQB);



@end


